package net.zoneland.knowledge.dao;

import java.util.List;
import net.zoneland.knowledge.model.DataCategory;
import net.zoneland.knowledge.model.DataCategoryExample;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

@Mapper
public interface DataCategoryMapper {
    @SelectProvider(type=DataCategorySqlProvider.class, method="countByExample")
    long countByExample(DataCategoryExample example);

    @Delete({
        "delete from AITK_DATA_CATEGORY",
        "where ID = #{id,jdbcType=VARCHAR}"
    })
    int deleteByPrimaryKey(String id);

    @Insert({
        "insert into AITK_DATA_CATEGORY (ID, CATEGORY_KEY, ",
        "CATEGORY_LABEL, REMARK, CREATETIME, ",
        "UPDATETIME, SORT, ",
        "SCRIPT)",
        "values (#{id,jdbcType=VARCHAR}, #{key,jdbcType=VARCHAR}, ",
        "#{label,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR}, #{createtime,jdbcType=TIMESTAMP}, ",
        "#{updatetime,jdbcType=TIMESTAMP}, #{sort,jdbcType=VARCHAR}, ",
        "#{script,jdbcType=CLOB})"
    })
    int insert(DataCategory record);

    @InsertProvider(type=DataCategorySqlProvider.class, method="insertSelective")
    int insertSelective(DataCategory record);

    @SelectProvider(type=DataCategorySqlProvider.class, method="selectByExampleWithBLOBs")
    @Results({
        @Result(column="ID", property="id", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="CATEGORY_KEY", property="key", jdbcType=JdbcType.VARCHAR),
        @Result(column="CATEGORY_LABEL", property="label", jdbcType=JdbcType.VARCHAR),
        @Result(column="REMARK", property="remark", jdbcType=JdbcType.VARCHAR),
        @Result(column="CREATETIME", property="createtime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="UPDATETIME", property="updatetime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="SORT", property="sort", jdbcType=JdbcType.VARCHAR),
        @Result(column="SCRIPT", property="script", jdbcType=JdbcType.CLOB)
    })
    List<DataCategory> selectByExampleWithBLOBs(DataCategoryExample example);

    @SelectProvider(type=DataCategorySqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="ID", property="id", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="CATEGORY_KEY", property="key", jdbcType=JdbcType.VARCHAR),
        @Result(column="CATEGORY_LABEL", property="label", jdbcType=JdbcType.VARCHAR),
        @Result(column="REMARK", property="remark", jdbcType=JdbcType.VARCHAR),
        @Result(column="CREATETIME", property="createtime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="UPDATETIME", property="updatetime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="SORT", property="sort", jdbcType=JdbcType.VARCHAR)
    })
    List<DataCategory> selectByExample(DataCategoryExample example);

    @Select({
        "select",
        "ID, CATEGORY_KEY, CATEGORY_LABEL, REMARK, CREATETIME, UPDATETIME, SORT, SCRIPT",
        "from AITK_DATA_CATEGORY",
        "where ID = #{id,jdbcType=VARCHAR}"
    })
    @Results({
        @Result(column="ID", property="id", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="CATEGORY_KEY", property="key", jdbcType=JdbcType.VARCHAR),
        @Result(column="CATEGORY_LABEL", property="label", jdbcType=JdbcType.VARCHAR),
        @Result(column="REMARK", property="remark", jdbcType=JdbcType.VARCHAR),
        @Result(column="CREATETIME", property="createtime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="UPDATETIME", property="updatetime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="SORT", property="sort", jdbcType=JdbcType.VARCHAR),
        @Result(column="SCRIPT", property="script", jdbcType=JdbcType.CLOB)
    })
    DataCategory selectByPrimaryKey(String id);

    @UpdateProvider(type=DataCategorySqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") DataCategory record, @Param("example") DataCategoryExample example);

    @UpdateProvider(type=DataCategorySqlProvider.class, method="updateByExampleWithBLOBs")
    int updateByExampleWithBLOBs(@Param("record") DataCategory record, @Param("example") DataCategoryExample example);

    @UpdateProvider(type=DataCategorySqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") DataCategory record, @Param("example") DataCategoryExample example);

    @UpdateProvider(type=DataCategorySqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(DataCategory record);

    @Update({
        "update AITK_DATA_CATEGORY",
        "set CATEGORY_KEY = #{key,jdbcType=VARCHAR},",
          "CATEGORY_LABEL = #{label,jdbcType=VARCHAR},",
          "REMARK = #{remark,jdbcType=VARCHAR},",
          "CREATETIME = #{createtime,jdbcType=TIMESTAMP},",
          "UPDATETIME = #{updatetime,jdbcType=TIMESTAMP},",
          "SORT = #{sort,jdbcType=VARCHAR},",
          "SCRIPT = #{script,jdbcType=CLOB}",
        "where ID = #{id,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKeyWithBLOBs(DataCategory record);

    @Update({
        "update AITK_DATA_CATEGORY",
        "set CATEGORY_KEY = #{key,jdbcType=VARCHAR},",
          "CATEGORY_LABEL = #{label,jdbcType=VARCHAR},",
          "REMARK = #{remark,jdbcType=VARCHAR},",
          "CREATETIME = #{createtime,jdbcType=TIMESTAMP},",
          "UPDATETIME = #{updatetime,jdbcType=TIMESTAMP},",
          "SORT = #{sort,jdbcType=VARCHAR}",
        "where ID = #{id,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKey(DataCategory record);
}